package com.bank.controller;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bank.exception.CommonException;
import com.bank.service.SubjectService;

@Controller
public class SubjectController  extends BaseController{
	
	
	Logger logger = Logger.getLogger(SubjectController.class);

	@Autowired
	SubjectService subjectService;
	
	@RequestMapping(value="addSubjet.do", method=RequestMethod.POST)
	public @ResponseBody Map<String,Object> addSubject(@RequestBody Map<String,Object> params) throws CommonException{
		logger.debug("开始调用增加机构");
		subjectService.save(params);
		return this.setAndGetSuccess();		
	}
	
	@RequestMapping(value="updateSubject.do", method=RequestMethod.POST)
	public @ResponseBody Map<String,Object> updateSubject(@RequestBody Map<String,Object> params) throws CommonException{
		logger.debug("开始调用更新机构");
		subjectService.update(params);
		return this.setAndGetSuccess();
	}
	
	@RequestMapping(value="getSubjectList.do", method=RequestMethod.POST)
	public @ResponseBody Map<String,Object>  getSubjectList(@RequestBody Map<String,Object> params){
		//查询机构列表
		List<Object> value = subjectService.getSubjectList(params);
		this.setMapListValue("data", value);
		return this.returnMap();
	}

}
